import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2

import "matrix_js.js" as MAT
Dialog {
    id:dialog
    visible: true
    title: "Create Matrix"
    property int row: 10
    property string txt: "value"

    contentItem: Rectangle {
        id:recinCreate
        color: "#EEEEEE"
        implicitWidth: 600
        implicitHeight: 400

        Rectangle{
            id:matrixSaveInHere
            width: 600
            height: 400
            anchors.top:parent.top

            Text{
                id:textarea
                text: MAT.initMatrix()
                font.pixelSize: 25
                anchors.centerIn: matrixSaveInHere
            }
        }

        RowLayout{
            anchors.bottom: bot.top
            Text{
                text: "Row:"
                width: 30
            }
            TextField{
                id:row
                text:""
                width: 10
            }


            Text{
                text:"Column:"
                width: 30
            }

            TextField{
                id:column
                text:""
                width: 10
            }

            Text{
                text:"Value:"
                width: 30
            }

            TextField{
                id:value
                text:""
                width: 10
            }
            Button{
                text:"修改"
                width: 50
                onClicked: {
                    if(MAT.verify(row.text) == false){
                        MAT.errorInValid();
                        return;
                    }
                    if(MAT.verify(column.text) == false){
                        MAT.errorInValid();
                        return;
                    }
                    if(MAT.verify(value.text) == false){
                        MAT.errorInValid();
                        return;
                    }
                    MAT.modify(row.text,column.text,value.text);
                }
            }

        }

        RowLayout{
            id:bot
            anchors.bottom: parent.bottom
            Button{
                text:"获取数据"
                onClicked: {
                    MAT.initMatrix();
                }
            }

            Button{
                text:"退出"
                anchors.bottom: parent.bottom
                anchors.right: parent.right
                onClicked: {
                    dialog.destroy();
                }
            }
        }
    }
}

